//@author A0105740R

package rightnow.parser.cmdline;

/**
 * This parser parses arguments for command "delete".
 */
final class CmdDelParser {
	
	private static final String STR_DONE = "done";
	
	/**
	 * Parses an argument string and stores the result in a command parser bucket.
	 * @param bucket != null
	 * @param str != null
	 * @throws CmdParserException
	 */
	public static void parseInto(CmdParserBucket bucket, String str) 
			throws CmdParserException {
		if (STR_DONE.equalsIgnoreCase(str)) {
			bucket.setCmdType(CommandType.DELETE_DONE);
		}
		else {
			try {
				bucket.setInt(Integer.parseInt(str));
			}
			catch (NumberFormatException e) {
				throw new CmdParserException(CmdParserErrorMsg.ERROR_FORMAT_DEL);
			}
		}
	}
}
